home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.09 Sep 90 / Object1 Folder / DrawMyStuff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-11  |  1.4 KB  |  57 lines  |  [TEXT/KAHL]

  1. /*
  2.  *    Source    - DrawMyStuff.c
  3.  *    Author    - Mark Bykerk Kauffman
  4.  *    Purpose    -    To demonstrate how to create instances of objects and send them
  5.  *                messages using Think C 4.0.  Call this function in the Draw 
  6.  *                method for the Pane of your application.
  7.  * 
  8.  */
  9.  
  10. #include "oops.h"                
  11. #include "CShape.h"
  12.  
  13. /*            
  14.  * oops.h is included so the compiler knows how to deal with the object      
  15.  * oriented-programming in this section of code.  CShape.h is included        
  16.  * so all of the shapes defined in CShape.h are available.                                              
  17.  */
  18.  
  19. void DrawMyStuff()
  20. {
  21.     int            i;
  22.     CLine        *ALine;
  23.     COval        *AnOval[4];
  24.     CRectangle    *ARectangle[4];
  25.     
  26.     for (i=0;i<4;i++) 
  27.         ARectangle[i] = new(CRectangle);
  28.     ARectangle[0]->SetShapeLoc(200,100,300,200);
  29.     ARectangle[1]->SetShapeLoc(210,110,290,190);
  30.     ARectangle[2]->SetShapeLoc(220,120,280,180);
  31.     ARectangle[3]->SetShapeLoc(230,130,270,170);
  32.     for (i=0;i<4;i++) 
  33.         ARectangle[i]->Draw();
  34.     
  35.     ALine = new(CLine);                         
  36.     ALine->SetShapeLoc(210,110,290,110);
  37.     ALine->Erase();
  38.     ALine->SetShapeLoc(100,50,300,50);         
  39.     ALine->Draw();
  40.     
  41.     for (i=0;i<4;i++) 
  42.         AnOval[i] = new(COval);
  43.     AnOval[0]->SetShapeLoc(100,100,200,200);
  44.     AnOval[1]->SetShapeLoc(110,110,190,190);
  45.     AnOval[2]->SetShapeLoc(120,120,180,185);  
  46.     AnOval[3]->SetShapeLoc(130,130,170,170);
  47.     for (i=0;i<4;i++) 
  48.         AnOval[i]->Draw();
  49.     
  50.     for (i=0;i<4;i++)
  51.     { 
  52.         delete(ARectangle[i]); 
  53.         delete(AnOval[i]);
  54.     }
  55.     delete(ALine);
  56. }
  57.